import { defineConfig } from "vite";
import glsl from 'vite-plugin-glsl';
import { resolve } from 'path';
import CopyPlugin from "vite-copy-plugin";
const lib_name = 'cesium-3d-wind';
export default defineConfig({
  plugins: [
    glsl(),
    CopyPlugin([
      { from: 'src/index.d.ts', to: 'dist/types' }
    ])
  ],

  alias: {
    '@': resolve(__dirname, 'src')
  },

  build: {
    lib: {
      entry: resolve(__dirname, 'src/index.js'),
      name: lib_name,
      fileName: (format) => `${lib_name}.${format}.js`
    },
    minify: "terser",
    rollupOptions: {
      // 确保外部化处理那些你不想打包进库的依赖
      external: ['cesium'],
      output: {
        globals: {
          cesium: 'Cesium'
        }
      }
    },
    terserOptions: {
      compress: {
        drop_console: true
      }
    }
  }
});